package com.ddyx.rest;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ddyx.service.EventClickFavoriteService;
import com.ddyx.service.ICartService;
import com.ddyx.util.RequestForm;
import com.ddyx.util.ResponseForm;

/**
 * @ClassName: CartController.java
 * @Description: 购物车相关功能
 * @author: liuhoujie
 * @date: 2018年1月16日
 */

@Controller
@RequestMapping("/cart")
public class CartController {
	@Resource
	ICartService cartService;
	
	/**
	 * @desc 购物车页
	 * @param param
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="CartPage",method = RequestMethod.POST)
	public ResponseForm CartPage(@RequestBody RequestForm param) {
		return cartService.CartPage(param);
	}
	
	
	/**
	 * @desc 批量加入购物车
	 * @param param
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "batchCart" , method = RequestMethod.POST)
	public ResponseForm batchCart(@RequestBody RequestForm param) {
		return cartService.batchCart(param);
	}

	/**
	 * 获取购物车
	 *
	 * @param param
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/v1.5/get", method = RequestMethod.POST)
	public ResponseForm get(@RequestBody RequestForm param) {
		return cartService.getCart(param);
	}

	/**
	 * 添加商品进购物车
	 *
	 * @param param
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/v1.5/add", method = RequestMethod.POST)
	public ResponseForm add(@RequestBody RequestForm param) {
		return cartService.insertOrUpdateGoodsToCart(param);
	}

	/**
	 * 修改购物车商品属性
	 *
	 * @param param
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/v1.5/modify", method = RequestMethod.POST)
	public ResponseForm modify(@RequestBody RequestForm param) {
		return cartService.modifyGoodsInCart(param);
	}

	/**
	 * 删除购物车内商品
	 *
	 * @param param
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/v1.5/remove", method = RequestMethod.POST)
	public ResponseForm remove(@RequestBody RequestForm param) {
		return cartService.removeGoodsInCart(param);
	}

	/**
	 * 清空购物车
	 *
	 * @param param
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/v1.5/empty", method = RequestMethod.POST)
	public ResponseForm empty(@RequestBody RequestForm param) {
		return cartService.emptyCart(param);
	}


}
